package com.wechat.server.mp.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @description:
 * @author: stone
 * @date: Created by 2021/10/10 15:33
 * @version: 1.0.0
 * @pakeage: com.wechat.server.mp.config
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private HandlerInterceptor authInterceptor;


    /**
     * 实现 WebMvcConfigurer 中的添加拦截器方法
     *
     * @param registry 拦截器注册表
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //使用拦截器注册表进行添加 自定义拦截器
        registry.addInterceptor(authInterceptor)
                //添加拦截路径
                .addPathPatterns("/excel/excel","/excel/export")
                //设置放行路径
                .excludePathPatterns("/excel/code");
    }
}
